﻿using System.Collections.Generic;
using System.Data.SqlClient;
using VentaElectrodomesticos.Contrato;
using System.Linq;
using System.Text;
using System;

namespace VentaElectrodomesticos.Datos
{
    public class ObjectBuilder<T> where T : Entity, new()
    {
        private T entity;
        private Dictionary<String, object> properties = new Dictionary<string,object>();

        public ObjectBuilder(T entity)
        {
            this.entity = entity;
            this.properties = Introspection<T>.getRunTimeProperties(entity);
        }

        public T getObject(SqlDataReader reader)
        {                        
            this.entity = Introspection<T>.setPropertiesFromReader(entity, reader);
            return this.entity;
        }
    }
}
